<div class="box_right">
    <h1>用户编辑</h1>
    <div class="pro_box layui-form">
        <div class="layui-form-item">
			<div class="layui-inline" style="width: 100%;">
			<?php if (validation_errors()!=''){?>
	        <div id="info_msg" class="alert alert-danger"><?php echo validation_errors();?></div>
	        <?php }?>
	            <!-- general form elements disabled -->
	                <form id="usrform" role="form" action="<?php echo base_url().'gasstation/systems/edit_user';?>" method="post">
	                	<input type="hidden" name="user_id" value="<?php if (isset($admin->id))echo $admin->id;?>">
	                	<div class="box-body" style="display: inline-block;width: 100%">
	                        <div class="form-group col-xs-6">
	                            <label>用户名</label>
	                            <input name="login_name" type="text" class="layui-input" placeholder="输入 ..." value="<?php if (isset($admin->login_name))echo $admin->login_name;?>" datatype="*" nullmsg="请输入用户名！">
	                        </div>
	                        <div class="form-group col-xs-6">
	                            <label>密码</label>
	                            <input name="password" type="password" class="layui-input" placeholder="输入 ..." value="******" datatype="*" nullmsg="请输入密码！">
	                        </div>
	                        <div class="form-group col-xs-6">
	                            <label>姓名</label>
	                            <input name="user_name" type="text"  class="layui-input" placeholder="输入 ..." value="<?php if (isset($admin->user_name))echo $admin->user_name;?>" datatype="*" nullmsg="请输入姓名！">
	                        </div>
	                        <div class="form-group col-xs-6">
	                            <label>联系电话</label>
	                            <input name="user_phone" type="text"  class="layui-input" placeholder="输入 ..." value="<?php if (isset($admin->user_phone))echo $admin->user_phone;?>"  datatype="*" nullmsg="请输入联系电话！">
	                        </div>
	                        <hr>
	                        <div class="form-group col-xs-12">
	                        	<label>用户权限</label>
		                        <div class="col-xs-12" style="border: 1px solid #dfdfdf;padding: 0px;">
			                        <?php if (isset($acl)&&count($acl)>0){
			                        	foreach ($acl as $val){
			                        	?>
			                        <div class="checkbox" style="border-bottom: 1px solid #dfdfdf;">
										<label>
											<input lay-ignore type="checkbox" name="acl_id[]" value="<?php echo $val->id?>" <?php if (in_array($val->id, explode(',', $admin->acl)))echo "checked";?>/>
											<span class="lbl">&nbsp;<?php echo $val->acl_name?></span>
										</label>
										<?php if (count($val->child_acl)>0){
											foreach ($val->child_acl as $child){
											?>
										<div class="checkbox" style="padding-left: 25px;border-top: 1px solid #dfdfdf;">
											<label>
											<input lay-ignore type="checkbox" name="acl_id[]" value="<?php echo $child->id?>" <?php if (in_array($child->id, explode(',', $admin->acl)))echo "checked";?>/>
											<span class="lbl">&nbsp;<?php echo $child->acl_name?></span>
											</label>
											<?php if (count($child->child_acl)>0){
											foreach ($child->child_acl as $child_child){
											?>
											<div class="checkbox" style="padding-left: 25px;">
												<label>
												<input lay-ignore type="checkbox" name="acl_id[]" value="<?php echo $child_child->id?>"  <?php if (in_array($child_child->id, explode(',', $admin->acl)))echo "checked";?>/>
												<span class="lbl">&nbsp;<?php echo $child_child->acl_name?></span>
												</label>
												<?php if (count($child_child->child_acl)>0){
												foreach ($child_child->child_acl as $child_child_child){
												?>
												<label style="margin-left: 15px;">
												<input lay-ignore type="checkbox" name="acl_id[]" value="<?php echo $child_child_child->id?>"  <?php if (in_array($child_child_child->id, explode(',', $admin->acl)))echo "checked";?>/>
												<span class="lbl"><?php echo $child_child_child->acl_name?></span>
												</label>
												<?php }
												}?> 
											</div>
											<?php }
											}?> 
										</div>
										<?php }
											}?>                                            
									</div>
									<?php }
		                        	}?>
		                        </div>
		                   	</div>
	                        
	                	</div><!-- /.box-body -->
                	<div class="clearfix form-actions">
						<div class="col-md-offset-3 col-md-9">
							<button id="btnSubmit" class="btn btn-info" type="submit">
								<i class="icon-ok bigger-110"></i>
								保存
							</button>

							&nbsp; &nbsp; &nbsp;
							<a class="btn btn-warning" href="<?php echo base_url()."gasstation/systems/user"?>">
								<i class="icon-undo bigger-110"></i>
								返回
							</a>
						</div>
					</div>
                </form>
	        </div>
		</div>
    </div>
</div>
<style>
.checkbox label {
    display: inline-block;
}
.checkbox input[type="checkbox"] {
	margin-left: 0px;
}
</style>
<script>
//Demo
layui.use(['form','element','laydate'], function(){
  var form = layui.form,
  	element = layui.element,
  	laydate = layui.laydate;
});
</script>
<script type="text/javascript">
//验证表单
$(function(){
    $.Tipmsg.r=null;
    $("#usrform").Validform({
        tiptype:function(msg){
            layer.msg(msg);
        },
        tipSweep:true,
        ajaxPost:false
    });
})
$('div > label:first-child input:checkbox').on('click' , function(){
	var that = this;
	$(this).closest('div').find('div input:checkbox')
	.each(function(){
		this.checked = that.checked;;
	});
});
</script>